package Lee_code;

import java.util.HashSet;

public class Lee_202_2 {
    public boolean isHappy(int n)
    {
        HashSet<Integer> hashSet = new HashSet<>();
        while(n!=1)
        {
            if(!hashSet.contains(n))
            {
                hashSet.add(n);
                n = get_next(n);
            }
            else
            {
                break;
            }
        }
        return false;
    }
    public static int get_next(int n)
    {
        int sum = 0;
        while(n!=0)
        {
            int temp = n % 10;
            sum = sum + temp * temp;
            n = n / 10;
        }
        return sum;
    }
}
